// This file is an attempt at making the current codebase responsive for select
// pages in the Firefox accounts auth flow.

.menu-toggle,
.close-menu {
  display: none; // this is displayed below, but hidden by default.
}

.lock-body {
  overflow: hidden;
  position: fixed;
  height: 100vh;
}

#get-involved-box {
  margin: 0 auto;
  display: block;
}

.responsive {
  min-width: 0;

  #mobile-warning {
    display: none;
  }

  #main-content {
    margin-top: 0;
  }

  #main-content > .grid_12 {
    margin: 0;
  }

  .search-form-large,
  .responsive.html-ltr .container_12 .grid_12, .responsive.html-rtl .container_12 .grid_12.search-form-large {
    padding: 0;
    max-width: 100%
  }

  .container_12 [class*="grid_"],
  .container_12 {
    width: 100%;
    box-sizing: border-box;
    float: none;
  }

  .container_12 [class*="grid_"][class*="prefix_"] {
    width: auto;
  }

  .container_12 {
    width: 100%;
    max-width: 960px;
  }

  &.html-ltr,
  &.html-rtl {
    .container_12 {
      .grid_12 { max-width: 960px; }
      .grid_11 { max-width: 860px; }
      .grid_10 { max-width: 780px; }
      .grid_9 { max-width: 700px; }
      .grid_8 { max-width: 620px; }
      .grid_7 { max-width: 540px; }
      .grid_6 { max-width: 460px; }
      .grid_5 { max-width: 380px; }
      .grid_4 { max-width: 300px; }
      .grid_3 { max-width: 220px; }
      .grid_2 { max-width: 140px; }
      .grid_1 { max-width: 60px; }
    }
  }

  &.html-ltr .container_12 .language-picker,
  &.html-rtl .container_12 .language-picker {
    width: 130px;
    padding: 0;
    margin: 10px 0 20px 0;
    display: block;

  }

  .menu-toggle {
    display: flex;
    justify-content: center;
    align-self: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    padding-right: 10px;
    color: #fff;
  }

  &.html-rtl .menu-toggle {
    margin-right: auto;
    margin-left: 10px;
  }

  &.scroll-header:not(.lock-body) .menu-toggle {
    display: none;
  }

  .menu-icon {
    max-width: 6px;
    width: 100%;
  }

  @media screen and (min-width: 970px) {
    .container_12 [class*="grid_"],
    .container_12 {
      box-sizing: content-box;
    }

    .container_12 [class*="grid_"] {
      float: left;
    }

    &.register .container_12 .grid_12 {
      float: none;
    }

    &.profile #main-content {
      max-width: 680px;
      float: left;
    }

    .container_12 .grid_4 {
      max-width: 285px;
    }

    &.html-ltr .container_12 .language-picker {
      margin-left: 130px;
    }

    .menu-toggle {
      display: none;
    }
  }


  // make nav responsive
  @media screen and (max-width: 969px) {
    .nav-flex {
      display: flex;

      .responsive-nav-wrap {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: 80vw;
        z-index: 100;
        background: #000;
        transform: translateX(100%);
        transition: transform 0.2s ease-in-out;

        .nav-wrap-scroll {
          position: relative;
          top: 0;
          bottom: 0;
          overflow-y: auto;
          overflow-x: hidden;
          -webkit-overflow-scrolling: touch;
        }

        &.is-open { // off-canvas nav is open
          transform: translateX(0);
          box-shadow: 0 0 30px 16px rgba(0, 0, 0, 0.8);

          #aux-nav,
          #aux-nav-right {
            padding: 60px 0 0;

            > ul {
              display: flex;
              flex-direction: column;
              margin: 0;
              width: 100%;

               > li {
                 display: block;
                 padding: 0;
                 margin: 0;

                 &.lang-switcher-nav-item {
                   display: inline-flex;
                   padding-left: 16px;
                 }

                 > a {
                   display: inline-flex;
                   align-items: center;
                   width: 100%;
                   height: auto;
                   line-height: 1.4em;
                   box-sizing: border-box;

                   &.hidden {
                     display: none;
                   }

                   &.signin-signup-button {
                     background: transparent;
                     font-weight: bold;
                     color: #fff;
                     justify-content: flex-start;
                     border-radius: 0;
                   }

                   &.firefox-download-button {
                     font-weight: bold;
                     text-align: center;
                     justify-content: center;
                     width: calc(~"100% - 40px");
                     padding: 10px 12px;
                     margin: 10px 20px;
                   }
                 }

                 &.dropdown:not(.is-open) > a {
                   &:after {
                     display: block;
                     margin: 0 0 -3px auto;
                     width: 16px;
                     height: 20px;
                     background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10.8 17.23'%3E%3Cpolyline points='1.19 16.17 8.68 8.68 1.06 1.06' fill='none' stroke='%23fff' stroke-width='3'/%3E%3C/svg%3E");
                     background-repeat: no-repeat;
                     background-size: auto 100%;
                     content: "";
                   }
                 }

                 &.dropdown.is-open {
                  > ul {
                    display: block;
                    background: transparent;
                    position: static;
                    width: auto;
                    padding-top: 0;

                    &:after {
                      content: none;
                    }
                  }

                  li {
                    float: none;
                    width: auto;

                    &:hover,
                    a:hover {
                      background: transparent;
                    }
                  }

                  > a {
                    font-weight: bold;
                    position: relative;
                    z-index: 110; // above close button

                    &:before {
                      display: inline-block;
                      margin: 0 6px -3px 0;
                      width: 16px;
                      height: 20px;
                      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10.8 17.23'%3E%3Cpolyline points='9.61 1.06 2.12 8.55 9.74 16.17' fill='none' stroke='%23fff' stroke-width='3'/%3E%3C/svg%3E");
                      background-repeat: no-repeat;
                      background-size: auto 100%;
                      content: "";
                    }
                  }
                }
              }
            }

            a:not(.firefox-download-button) {
              color: #fff;
              text-decoration: none;
              font-size: 16px;
              font-weight: normal;
              padding: 15px 20px;
              border-top: 1px solid #161616;

              &:hover {
                text-decoration: none;
              }

              &.locale-picker {
                padding-left: 10px;
                border-top: 0 none;
              }
            }

            li:last-child > a {
              border-bottom: 1px solid #161616;
            }

            li.ff-btn-wrap {
              border-top: 1px solid #161616;
            }
          }

          #aux-nav > ul > li:hover > ul,
          #aux-nav-right > ul > li:hover > ul {
            display: none;
          }

          #aux-nav-right {
            padding-top: 0;
          }

          .push-right {
            margin-left: 0;
          }

          .close-menu {
            display: flex;
            justify-content: flex-end;
            position: absolute;
            z-index: 100;
            top: 0;
            right: 0;
            left: 0;
            height: 36px;
            padding: 10px 20px;
            color: #fff;

            &:after{
              position: absolute;
              width: 20vw;
              height: 99vh;
              left: -20vw;
              top: 0;
              content: "";
            }
          }

          .close-icon {
            max-width: 16px;
            width: 100%;
          }
        }

        &.is-second-level { // selectively hide top-level siblings when second level is open
          #aux-nav,
          #aux-nav-right {
            > ul {
              &:after {
                content: none;
              }

              > li,
              > li.lang-switcher-nav-item {
                display: none;

                &.dropdown.is-open {
                  display: block;
                  margin-top: -10px;
                }
              }
            }
          }

          .close-menu {
            left: auto;

            &:after {
              left: auto;
              right: calc(100vw - 20vw);
            }
          }
        }
      }
    }

    &.html-rtl .nav-flex .responsive-nav-wrap.is-open #aux-nav > ul > li.dropdown:not(.is-open) > a::after,
    &.html-rtl .nav-flex .responsive-nav-wrap.is-open #aux-nav-right > ul > li.dropdown:not(.is-open) > a::after {
      margin-right: auto;
      margin-left: 0;
      transform: rotate(180deg);
    }

    &.html-rtl .nav-flex .responsive-nav-wrap.is-second-level .close-menu {
      left: 0;
      right: auto;
    }

    &.html-rtl .nav-flex .responsive-nav-wrap.is-open #aux-nav > ul > li.dropdown.is-open > a::before,
    &.html-rtl .nav-flex .responsive-nav-wrap.is-open #aux-nav-right > ul > li.dropdown.is-open > a::before {
      margin: 0 0 -3px 6px;
      transform: rotate(180deg);
    }
  }

  @media screen and (max-width: 969px) {
    .hide-mobile {
      display: none;
    }

    .content-box {
      padding: 0;
    }

    .center-on-mobile {
      text-align: center;
    }

    .border-top-on-mobile {
      border-top: 1px solid @borderLightGrey;
      padding-top: 40px;
      margin-top: 20px;
    }

    &.light-grey-bg {
      background: #fff;

      .content {
        box-shadow: none;
      }

      #main-content {
        margin: 0 -20px 0;
        padding-top: 1px;
      }
    }

    #edit-profile {
      padding: 0;
    }

    .login-form {
      padding: 0 10px;
    }
  }
}

@media screen and (min-width: 970px) {
  .responsive-nav-wrap,
  .nav-wrap-scroll {
    display: flex;
    width: 100%;
  }

  .show-mobile {
    display: none;
  }

  #main-content {
    margin-top: 30px;
  }
}
